<?php
//比如像创建一个被全局应用的数据
class Preferences{
    private $props = array();
    private static $instance;

    private function __construct()
    {
    }
    public function setProperty($key,$val){
        $this->props[$key] = $val;
    }
    public function getProperty($key){
        return $this->props[$key];
    }

    public static function getInstance(){
        if(empty(self::$instance)){
            self::$instance = new Preferences();
        }
        return self::$instance;
    }
}

$pro = Preferences::getInstance();
$pro->setProperty('name','张三');
unset($pro);
$pro2 = Preferences::getInstance();
print $pro2->getProperty('name');